package Demo;

import java.util.ArrayList;

import java.util.Collections;
import java.util.HashMap;

public class DouDiZhu {
	public static void main(String[] args) {
		ArrayList<String> poker=new ArrayList<>();
		String[] colors={"♠","♣","♦","♥"};
		
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		poker.add("大王");
		poker.add("小王");
		
		HashMap<String, Integer> map = new HashMap<String, Integer>();

        int index = 0;
        map.put("大王", index++);
        map.put("小王", index++);

        for (String number : numbers) {
            for (String color : colors) {
                String card = color + number;
                poker.add(card);
                map.put(card, index++);
            }
        }		
		System.out.println(poker);
		Collections.shuffle(poker);
		//System.out.println(poker);
		Player p1=new Player();p1.setName("A");
		Player p2=new Player();p2.setName("B");
		Player p3=new Player();p3.setName("C");
		ArrayList<String> dipai=new ArrayList<>();
		for(int i=0;i<poker.size();i++){
			String p=poker.get(i);
			if(i>=51){
				dipai.add(p);
				
			}else if(i%3==0){
				p1.getPoker().add(p);
			}else if(i%3==1){
				p2.getPoker().add(p);
			}else if(i%3==2){
				p3.getPoker().add(p);
			}
		}
		p1.getPoker().sort((c1, c2) -> Integer.compare(map.get(c1), map.get(c2)));
	    p2.getPoker().sort((c1, c2) -> Integer.compare(map.get(c1), map.get(c2)));
	    p3.getPoker().sort((c1, c2) -> Integer.compare(map.get(c1), map.get(c2)));
	    dipai.sort((c1, c2) -> Integer.compare(map.get(c1), map.get(c2)));
	    
		System.out.println(p1.getName()+"的牌"+p1.getPoker());
		System.out.println(p2.getName()+"的牌"+p2.getPoker());
		System.out.println(p3.getName()+"的牌"+p3.getPoker());
		System.out.println("地主牌"+dipai);

	}
}

